/**
 * @filename:LecturerServiceImpl Lecturer
 * @project constract  V1.0
 * Copyright(c) 2018 gong Co. Ltd.
 * All right reserved.
 */
package com.znufe.exam.service.impl;

import java.util.List;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.znufe.exam.domain.lecturer.LecturerResponseObject;
import com.znufe.exam.viewmodel.admin.lecturer.LecturerPageRequestVM;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.znufe.exam.domain.Lecturer;
import com.znufe.exam.repository.LecturerMapper;
import com.znufe.exam.service.LecturerService;

/**
 *
 * @Description:  讲师表——SERVICEIMPL
 * @Author:       gong
 * @CreateDate:   Lecturer
 * @Version:      V1.0
 *
 */
@Service
public class LecturerServiceImpl extends BaseServiceImpl<Lecturer> implements LecturerService {

	private final LecturerMapper lecturerMapper;

	//查询对象
	@Autowired
	public LecturerServiceImpl(LecturerMapper lecturerMapper) {

		super(lecturerMapper);
		this.lecturerMapper = lecturerMapper;
	}

	// 查询对象
	@Override
	public Lecturer selectByPrimaryKey(Integer id) {

		return lecturerMapper.selectByPrimaryKey(id);
	}

	// 删除对象
	@Override
	public int deleteByPrimaryKey(Integer id) {

		return lecturerMapper.deleteByPrimaryKey(id);
	}

	// 添加对象
	@Override
	public int insertSelective(Lecturer lecturer) {

		return lecturerMapper.insertSelective(lecturer);
	}

	// 修改对象
	@Override
	public int updateByPrimaryKeySelective(Lecturer lecturer) {

		return lecturerMapper.updateByPrimaryKeySelective(lecturer);
	}

	// 查询集合
	@Override
	public List<Lecturer> queryLecturerList(Lecturer lecturer) {

		return lecturerMapper.queryLecturerList(lecturer);
	}

    @Override
    public List<LecturerResponseObject> getLecturerListById(List<Integer> ids) {
        return lecturerMapper.getLecturerListById(ids);
    }

	// 按名字查询讲师信息
	@Override
	public Lecturer getLecturerByName(String lecturerName) {

		return lecturerMapper.getLecturerByName(lecturerName);
	}

	// 选择查询讲师信息（职称、讲师姓名）
	@Override
	public PageInfo<Lecturer> page(LecturerPageRequestVM requestVM) {
		return PageHelper.startPage(requestVM.getPageNum(), requestVM.getPageSize(),
					"id desc").doSelectPageInfo(() ->
					lecturerMapper.page(requestVM));
	}

    @Override
    public int deleteAllLecturerByTitle(Integer titleId) {
        return lecturerMapper.deleteAllLecturerByTitle(titleId);
    }
}
